//
//  ViewController.m
//  iOSApp01
//
//  Created by yxh on 2020/4/26.
//  Copyright © 2020 yxh. All rights reserved.
//

#import "ViewController.h"
#import "GTNNormalTableViewCell.h"
#import "GTDeleteCellView.h"

@interface ViewController ()<UITableViewDataSource,UITableViewDelegate,GTNNormalTableViewCellDelegate>

@end

@implementation ViewController

- (instancetype) init{
    self = [super init];
    if(self){
        self.tabBarItem.title =@"新闻";
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UITableView *tableV = [[UITableView alloc] initWithFrame:self.view.bounds];
    tableV.dataSource = self;
    tableV.delegate = self;
    [self.view addSubview:tableV];
    
}




- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 90;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    NSLog(@"-------");
    UIViewController *controller = [[UIViewController alloc] init];
    controller.view.backgroundColor = [UIColor blueColor];
    controller.title = [NSString stringWithFormat:@" 主题 - %@", @(indexPath.row)];
    controller.navigationItem.rightBarButtonItem =[[UIBarButtonItem alloc] initWithTitle: @"分享" style:UIBarButtonItemStylePlain target:self action:nil];
    
    [self.navigationController pushViewController:controller animated:YES];
    NSLog(@"%@", self.navigationController);
}




- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 20;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    GTNNormalTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"id"];
    if(!cell){
        cell = [[GTNNormalTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"id"];
        cell.delegate = self;
    }
 
    [cell layoutTableViewCell];
    return cell;
    
}

- (void)tableViewCell:(UITableViewCell *)tableViewCell clickDeleteButton:(UIButton *)deleteButton{
    GTDeleteCellView *view= [[GTDeleteCellView alloc] initWithFrame:self.view.bounds];
    [view showDeleteView];
}




@end
